package or;

import org.junit.jupiter.api.Test;


public class T2412 {
    public long minimumMoney(int[][] transactions) {
        long totalLose = 0;
        int mx = 0;
        for (int[] t : transactions) {
            totalLose += Math.max(t[0] - t[1], 0);
            mx = Math.max(mx, Math.min(t[0], t[1]));
        }
        return totalLose + mx;
    }
    @Test
    public void test() {

        System.out.println();
    }
}
